<?php
class Gallery_Form_ImageAddMulti extends Zend_Form {
	public function init() {
		$this->setMethod('post');
		$this->setEnctype(Zend_Form::ENCTYPE_MULTIPART);
        
		$file = new KontorX_Form_Element_File('image', array(
        	'required' => true,
        	'destination' => Gallery_Model_Image::UPLOAD_PATH,
        	'filters' => array(
        		'UniqName' => new KontorX_Filter_File_UniqName()
        	),
        	'validators' => array(
        		'upload' => array(
        			'validator' => 'Upload'),
        		'isImage' => array(
        			'validator' => 'IsImage'),
        		'size' => array(
        			'validator' => 'Size',
        			'options' => array(
        				'min' => '3kb',
        				'bytestring' => true)),
        		'count' => array(
        			'validator' => 'Count',
        			'options' => array(
        				'max' => 1))
        	)
        ));
        
        $file->addDecorator(new KontorX_Form_Decorator_File_Uploadify(array(
        	// umożliwienie przsyłania identyfikatora sesji
        	'script' => 'addmulti',
        	'scriptData' => array(session_name() => session_id()),
        	'multi' => true,
        	'onComplete' => 'function(event,queueID,fileObj,response,data){if (typeof console != "object") return; console.log(event);console.log(queueID);console.log(fileObj);console.log(response);console.log(data);}',
        	'onError' => 'function(event,queueID,fileObj,errorObj) {if (typeof console != "object") return; console.log(errorObj)}'
        )));

        $this
        	->addElement($file);
//            ->addElement(new KontorX_Form_Element_Db_Select('album_id', array(
//            	'label' => 'Album',
//                'description' => 'Wybierz album, do którego będzie należeć zdięcia',
//            	'required' => true,
//            	'tableName' => 'gallery_album',
//            	'tableCols' => array('key' => 'id','value' => 'name')
//            )));
	}
}